﻿using System;
using System.Collections.Generic;
using System.Net.Security;
using System.ServiceModel;
using UrimTumim.Timesheet.Services.DataContracts;

namespace UrimTumim.Timesheet.Services.ServiceContracts
{
    /// <summary>
    /// Defines the methods available through Timesheet Service.
    /// </summary>
    /// <typeparam name="TTaskIdentifier">Type of identifier used by Task.</typeparam>
    [ServiceContract(Namespace = "http://www.utnet.com.br/timesheet/1.0/", SessionMode = SessionMode.Required)]
    public interface ITimesheetService
    {
        /// <summary>
        /// Authenticates an user.
        /// </summary>
        /// <param name="userName">User name that uniquely identifies a Timesheet User.</param>
        /// <param name="password">Password used to authenticate the user.</param>
        [OperationContract(IsInitiating = true, ProtectionLevel = ProtectionLevel.EncryptAndSign)]
        void LogOn(string userName, string password);

        /// <summary>
        /// Terminates an user's session.
        /// </summary>
        [OperationContract(IsInitiating = false, IsTerminating = true)]
        void LogOff();

        /// <summary>
        /// Adds a Timesheet Entry for a given User for a given timesheet namespace.
        /// </summary>
        /// <param name="task">Task being annotated.</param>
        /// <param name="start">Start time of Timesheet Entry.</param>
        /// <param name="finish">Finish time of Timesheet Entry.</param>
        /// <param name="breakInterval">Interval of time to be discounted from Timesheet Entry.</param>
        /// <param name="comment">Comment about Timesheet Entry.</param>
        [OperationContract(IsInitiating = false)]
        void AddNew(TaskData task, DateTime start, DateTime finish, TimeSpan breakInterval, string comment);

        /// <summary>
        /// Starts a Timesheet with given Task.
        /// </summary>
        /// <param name="task">Task being annotated.</param>
        /// <param name="comment">Comment about Timesheet Entry.</param>
        [OperationContract(IsInitiating = false)]
        void StartTimesheet(TaskData task, string comment);

        /// <summary>
        /// Stops a running Timesheet.
        /// </summary>
        /// <param name="comment">Comment about Timesheet Entry.</param>
        [OperationContract(IsInitiating = false)]
        void StopTimesheet(string comment);

        /// <summary>
        /// Restarts a paused Timesheet.
        /// </summary>
        /// <param name="comment">Comment about Timesheet Entry.</param>
        [OperationContract(IsInitiating = false)]
        void RestartTimesheet(string comment);

        /// <summary>
        /// Pauses a running Timesheet. 
        /// </summary>
        /// <param name="comment">Comment about Timesheet Entry.</param>
        [OperationContract(IsInitiating = false)]
        void PauseTimesheet(string comment);

        /// <summary>
        /// Gets all Timesheet Entries of the current user between the given interval dates.
        /// </summary>
        /// <param name="start">Interval start date.</param>
        /// <param name="finish">Interval end date.</param>
        /// <returns>Returns a list of Timesheet Entries between the interval dates.</returns>
        [OperationContract(IsInitiating = false, Name = "GetTimesheetEntriesByInterval")]
        IList<TimesheetData> GetTimesheetEntries(DateTime start, DateTime finish);

        /// <summary>
        /// Gets all Timesheet Entries of the current user for the specified Task.
        /// </summary>
        /// <param name="task">Task being annotated.</param>
        /// <returns>Returns a list of Timesheet Entries for the Task.</returns>
        [OperationContract(IsInitiating = false, Name = "GetTimesheetEntriesByTask")]
        IList<TimesheetData> GetTimesheetEntries(TaskData task);
    }
}
